To export doors module to a csv

Hello,

  I am trying to export a module to a csv but in vain. Can anybody please help on this?

Eg. Module Data

Object Identifier  Text

1-2                        abcdef

2-3                        bcdef

3-4                          fghij

 

This module data to be exported into a csv with Object Identifier and Text as separate columns and the data coming under them to be in the respective columns.

This should be repeated for any of the additions of the columns in the module.

I wrote a sample script, but with some problems: How to write to different columns in csv, How to write <Object Number> kind of attribute to csv?

Stream outfile = write("SomeFilePathHere.csv")
Object o
string hdg,txt,objnum,notes,swmod,swimp,swid

for o in m do
{
  hdg = o."Object Heading"
  txt = o."Object Text"
  swmod = o."SW Module"
  notes = o."H_Notes/Comments"
  //objnum = o."<Object Number>"
  swimp=o."SW Implementation"
 // swid=o.<"ID">

print "hdg="
print hdg
print "txt="
print txt
print "swmod="
print swmod
print "swimp="
print swimp
print "notes="
print notes
//print "swid="
//print swid
//print "objnum="
//print objnum

print "\n"

outfile<<hdg<<txt<<"\t"
outfile<<swmod<<"\t"
outfile<<swimp<<"\t"<<notes<<"\n"
//(o."Object Text")
}

print"Done2"


LavanyaMallikarjuna - Tue Nov 01 00:55:19 EDT 2016

Re: To export doors module to a csv
Mathias Mamsch - Tue Nov 01 04:22:09 EDT 2016

There are a couple of CSV Posts out there with code, that is probably more stable than yours (e.g. regarding quoting, character encoding, etc.). Check them out using the search function of the forum. 

Regarding your questions: 

- Your code looks right, you are separating the different columns by tabular (\t) characters, but you should not that Csv stands for COMMA separated list (you are doing a Tab Separated Values (TSV)). So depending on your locale and the program you open the file with you need to either use semicolon (german), comma (english) for CSV. 

- You can change the ending of your file to .TSV and see if your program opens the file correctly. 

- In Excel you can define the separator to use in the settings. 

Hope this helps, regards, Mathias

Re: To export doors module to a csv
DOORSHAM - Tue Nov 01 06:27:29 EDT 2016

Both a csv and a tab delimited file have specification that describes what each is.  You could get the correct specification that you desire and become familiar with it as first step to achieving your goal.

Re: To export doors module to a csv
Mathias Mamsch - Tue Nov 01 07:41:46 EDT 2016

DOORSHAM - Tue Nov 01 06:27:29 EDT 2016

Both a csv and a tab delimited file have specification that describes what each is.  You could get the correct specification that you desire and become familiar with it as first step to achieving your goal.

As far as I know CSV did never make it to an official specification ... Things like encoding are most of the times tool specific, therefore it is not a good exchange standard.

There is an RFC though for the mime type: text/csv (which does not handle file encoding though, since that is handled by the protocol)

https://tools.ietf.org/html/rfc4180

Regards, Mathias

Re: To export doors module to a csv
DOORSHAM - Tue Nov 01 07:46:19 EDT 2016

Mathias Mamsch - Tue Nov 01 07:41:46 EDT 2016

As far as I know CSV did never make it to an official specification ... Things like encoding are most of the times tool specific, therefore it is not a good exchange standard.

There is an RFC though for the mime type: text/csv (which does not handle file encoding though, since that is handled by the protocol)

https://tools.ietf.org/html/rfc4180

Regards, Mathias

Don't know what you mean by official -- I believe Microsoft defined what csv means.  And for USA that is what works with DOORS.  Can't say for other countries.

Re: To export doors module to a csv
Mathias Mamsch - Tue Nov 01 07:58:27 EDT 2016

DOORSHAM - Tue Nov 01 07:46:19 EDT 2016

Don't know what you mean by official -- I believe Microsoft defined what csv means.  And for USA that is what works with DOORS.  Can't say for other countries.

But is there a specification from Microsoft for CSV? As far as I know there is no specification, thats why I was confused since you wrote there are specifications for those ... Can you maybe provide a link? 

Re: To export doors module to a csv
DOORSHAM - Tue Nov 01 08:22:35 EDT 2016

Mathias Mamsch - Tue Nov 01 07:58:27 EDT 2016

But is there a specification from Microsoft for CSV? As far as I know there is no specification, thats why I was confused since you wrote there are specifications for those ... Can you maybe provide a link? 

Here is one that should be good enough:  https://en.wikipedia.org/wiki/Comma-separated_values

Here is another :  https://tools.ietf.org/html/rfc4180

 

Looks like csv has been around longer than Microsoft has been

Re: To export doors module to a csv
LavanyaMallikarjuna - Wed Nov 02 03:39:13 EDT 2016

Thank you Mathias and Doorsham for the information !